# Install Git for Windows
Write-Host "Installing Git for Windows..." -ForegroundColor Green

# Download Git installer
$gitUrl = "https://github.com/git-for-windows/git/releases/download/v2.42.0.windows.2/Git-2.42.0.2-64-bit.exe"
$installerPath = "$env:TEMP\Git-installer.exe"

try {
    Write-Host "Downloading Git installer..." -ForegroundColor Yellow
    Invoke-WebRequest -Uri $gitUrl -OutFile $installerPath -UseBasicParsing
    
    Write-Host "Running Git installer..." -ForegroundColor Yellow
    Write-Host "Please follow the installation wizard. Recommended settings:" -ForegroundColor Cyan
    Write-Host "- Use Git from the Windows Command Prompt" -ForegroundColor Cyan
    Write-Host "- Use the OpenSSL library" -ForegroundColor Cyan
    Write-Host "- Checkout Windows-style, commit Unix-style line endings" -ForegroundColor Cyan
    Write-Host "- Use Windows' default console window" -ForegroundColor Cyan
    
    Start-Process -FilePath $installerPath -Wait
    
    Write-Host "Git installation completed!" -ForegroundColor Green
    Write-Host "Please restart PowerShell to use Git commands." -ForegroundColor Yellow
    
} catch {
    Write-Host "Download failed. Please manually download Git from: https://git-scm.com/download/win" -ForegroundColor Red
} finally {
    # Clean up
    if (Test-Path $installerPath) {
        Remove-Item $installerPath -Force
    }
}

Write-Host "After installation, you can verify Git with: git --version" -ForegroundColor Cyan